package com.eqdd.yiqidian.box.span;

import android.graphics.Color;
import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.view.View;

/**
 * @author吕志豪 .
 * @date 17-12-19  下午4:55.
 * Github :https://github.com/lvzhihao100
 * E-Mail：1030753080@qq.com
 * 简书 :http://www.jianshu.com/u/6e525b929aac
 */

public class NoLineClickSpan extends ClickableSpan {
    String color;

    private View.OnClickListener onClickListener;

    public NoLineClickSpan(String color, View.OnClickListener onClickListener) {
        super();
        this.color = color;
        this.onClickListener = onClickListener;
    }

    @Override
    public void updateDrawState(TextPaint ds) {
        //设置字体颜色
        ds.setColor(Color.parseColor(color));
        ds.setUnderlineText(false); //去掉下划线
    }

    @Override
    public void onClick(View v) {
        if (onClickListener != null) {
            onClickListener.onClick(v);
        }
    }
}
